<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp" %>

<!DOCTYPE html>
<html>
<head>
<title>选择企业</title>
<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">

	<section class="content">
		<div class=" box box-success">
			<div class="box-body">
				<div class="input">
					<div class="textalign1"><spring:message code="message.lable.qiYeMingCheng"/><spring:message code="message.yanZheng.maoHao"/></div> 
                        <div class="boxinput">
                        <input type="text" class="textinput" id="compName" placeholder="<spring:message code="message.lable.qiYeMingCheng"/>" />
                    	</div>
                    	
                	<div class="textalign1"><spring:message code="message.lable.qiYeBianMa"/><spring:message code="message.yanZheng.maoHao"/></div> 
                        <div class="boxinput">
                        <input type="text" class="textinput" id="compCode" placeholder="<spring:message code="message.lable.qiYeBianMa"/>" />
                   		</div>
					<div class="textalign1" >
					<button type="button" onclick="likeQuery();" class="btn btn-success btn-sm" id="selectDrug"><spring:message code="message.button.seachSpacing"/></button>
					</div>
				  </div>
			</div>
		</div>
		<table class="jqgrid" id="gridlist"></table>
		<div id="gridpage"></div>
		 <div class=" box box-warning bottongroup">
            <button type="button" id="confirm"  onclick="confirm();" class="btn btn-default btn-sm"><spring:message code="message.button.okSpacing"/></button>
        </div>
     </section>   
	<%@ include file="/WEB-INF/component/commonJS.jsp"%>
	<script type="text/javascript">
	
	//绑定回车
    $('#compCode,#compName,#area1,#area2,#area3').bind('keydown', function(event) {
        if (event.keyCode == "13") {        //13 位电脑上回车键的位置代码
            $('#selectDrug').click();
        }
    }); 
  
    $("#compName").focus();//加载页面光标在第一个查询框内 
    
		$(function() {
			$("#gridlist").jqGrid({
								url : "${ctx}/stdProdDrugInfo/getSelectComp.html?compType=${compType}",
								mtype : "POST",
								datatype : "json",
								autowidth : true,
								height : 270,
								colNames : [ 
								             'id',
								             'status',
								             '<spring:message code="message.lable.qiYeBianMa"/>', 
								             '<spring:message code="message.lable.qiYeMingCheng"/>',
								             '<spring:message code="message.listForm.qiYeLeiXing"/>'
								             ],
								colModel : [
											{name : 'prodCompId',width : 160,hidden:true,align : "center",sortable : false},
											{name : 'prodCompStatus',width : 160,hidden:true,align : "center",sortable : false},
											{name : 'compCode',width : 80,align : "center",sortable : false},
										    {name : 'compName',width : 160,align : "center",sortable : false},
										    {name : 'compType',width : 160,hidden:true,align : "center",sortable : false}
										 ],
								rowNum : 20,
								rowList : [ 10, 20, 50,100 ],
								rownumbers : true,
								pager : "#gridpage",
								viewrecords : true,
								caption : "<spring:message code="message.lable.qiYeXinXiChaKan"/>",
								jsonReader : {
									repeatitems : false,
									id : "ids"
								},
								gridComplete:function(){
			                        //序号列宽度自适应（参数为jqgridID）
			                        autoRNWidth("gridlist");
			                        //数据只有一条时默认选中（参数为jqgridID）
			                        selectByOneData("gridlist");
			                    }
							});
			$("#gridlist").jqGrid('navGrid', '#gridpage', {
				add : false,
				edit : false,
				del : false,
				search : false,
				refresh : false
			});

			 $(window).trigger("resize");
		});


		function likeQuery() {
			var code = $("#compCode").val();
			var compName = $("#compName").val();
		
			$("#gridlist").jqGrid('setGridParam',{
				       	    	datatype:'json',
				                postData:{
				                	"compCode":code,
				                	"compName":compName
				                	},
				                page : 1
			}).trigger("reloadGrid");
		}
	
        //确认
        function confirm() {
            var rowId = $("#gridlist").jqGrid("getGridParam", "selrow") || [];
             if(rowId.length <=0){
                $.HN.message.alert("<spring:message code="message.list.qingXuanZeYaoQueRenQiYe"/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code="message.HN.alert.type"/>", "warn");
                return;
             }
             var rowdata = $("#gridlist").jqGrid('getRowData', rowId);
             var dialog = top.dialog.get(window);
             var params = {
        		"prodCompId":rowdata.prodCompId,
        		"prodCompStatus":rowdata.prodCompStatus,
             	"compName" : rowdata.compName,
             	"compCode" : rowdata.compCode,
             	"compType" : rowdata.compType
             };
             dialog.close(params);   // 关闭（隐藏）对话框
             dialog.remove();        // 主动销毁对话框
        }

      
	</script>
</body>
</html>









